package myJs.implicits

import scala.scalajs.js
import scala.scalajs.js.JSON
import myJs.implicits.Implicits._

/**
 * Created by Administrator on 2020/1/16
 */
trait MyStringTool {

  type JArJDJAn=js.Array[js.Dictionary[js.Any]]
  type JArJDS=js.Array[js.Dictionary[String]]
  type JDJAn=js.Dictionary[js.Any]

  implicit class MyString(v: String) {

    def toJDS = {
      JSON.parse(v).toJDS
    }

    def toJDJAn = {
      JSON.parse(v).toJDJAn
    }

    def toJArJDS = {
      JSON.parse(v).toJArJDS
    }

    def toJArJDJAn = {
      JSON.parse(v).toJArJDJAn
    }

    def toLines = {
      v.mySplit("\r\n").notEmptyLines
    }

    def mySplit(sep: String = "\t") = {
      v.split(sep).toList
    }

  }

}
